function TTreeShow(){
    var setting = {
        view: {
            showLine: true,
            selectedMulti:true
        },
        async: {
            enable: true,
            url: "/dept/getDeptData",//url地址
            type: 'post',
            autoParam: ["id"],
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pid",
                rootPId: 0
            }
        },
        check: {
            enable: true,
            chkStyle: "checkbox"
        },
        callback: {
            onClick: zTreeOnClick,
            onAsyncError: zTreeOnAsyncError,
            onAsyncSuccess: function (event, treeId, treeNode, msg) {
            }
        }
    };

    function zTreeOnClick(event, treeId, treeNode) {
    }

    function zTreeOnAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
        alert("加载错误：" + XMLHttpRequest);
    }

    $(document).ready(function () {
        $.fn.zTree.init($("#Ttree"), setting);
    });
}

function STreeShow() {

    var setting = {
        view: {
            showLine: true,
            selectedMulti:true
        },
        async: {
            enable: true,
            url: "/dept/getDeptDataDetails",//url地址
            type: 'post',
            autoParam: ["id"],
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pid",
                rootPId: 0
            }
        },
        check: {
            enable: true,
            chkStyle: "checkbox"
        },
        callback: {
            onClick: zTreeOnClick,
            onAsyncError: zTreeOnAsyncError,
            onAsyncSuccess: function (event, treeId, treeNode, msg) {
            }
        }
    };

    function zTreeOnClick(event, treeId, treeNode) {
    }

    function zTreeOnAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
        alert("加载错误：" + XMLHttpRequest);
    }

    $(document).ready(function () {
        $.fn.zTree.init($("#Stree"), setting);
    });
}

function SConfirm() {
    var treeObj = $.fn.zTree.getZTreeObj("Stree");
    var nodes = treeObj.getCheckedNodes(true);
    if(0 === nodes.length) {
        alert("请选择需要通知的班级!");
        return;
    }
    var nodeNames = "";
    var nodeIds="";
    for(var i = 0; i < nodes.length; i++) {
        nodeNames+= nodes[i].name + " ";
        if(!nodes[i].isParent) {
            nodeIds += nodes[i].id + ",";
            nodeNames+=",\n";
        }
    }
    if (confirm("您确认发布公告通知给以下:\n"+nodeNames)) {
        $.post("/notice/createNotice",
            {
                "toDeptid": nodeIds,
                "title":$('#Stitle').val(),
                "content":$('#SMyContent').val()
            },
            function (response) {
                if (0 == response.code) {
                    alert("发布成功！")
                } else {
                    alert(response.msg);
                }
            });
    }

}

function TConfirm() {
    var treeObj = $.fn.zTree.getZTreeObj("Ttree");
    var nodes = treeObj.getCheckedNodes(true);
    if(0 === nodes.length) {
        alert("请选择需要通知的班级!");
        return;
    }
    var nodeNames = "";
    var nodeIds="";
    for(var i = 0; i < nodes.length; i++) {
        nodeNames+= nodes[i].name + " ";
        if(!nodes[i].isParent) {
            nodeIds += nodes[i].id + ",";
            nodeNames+= nodes[i].name + ",";
        }

    }
    if (confirm("您确认发布公告通知给以下?\n"+nodeNames)) {
        $.post("/notice/createNotice",
            {
                "toDeptid": nodeIds,
                "title":$('#Ttitle').val(),
                "content":$('#TMyContent').val()
            },
            function (response) {
                if (0 == response.code) {
                    alert("发布成功！")
                } else {
                    alert(response.msg);
                }
            });
    }

}
